﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;

namespace personalplaner.business.stamm
{
    public class DienstZeitCollection : CollectionBase<DienstZeit>
	{
		public DateTime DatumVon
        {
            get
            {
                return this.FirstOrDefault().DatumVon;
            }
        }

        public DateTime DatumBis
        {
            get
            {
                return this.FirstOrDefault().DatumBis;
            }
        }

        public bool IsAbteilungsZeit
        {
            get
            {
                return this.FirstOrDefault().IsAbteilungsZeit;
            }
        }

        public int DienstZeitId
        {
            get
            {
                return this.FirstOrDefault().DienstZeitId;
            }
        }

        public int DienstId
        {
            get
            {
                return this.FirstOrDefault().DienstId;
            }
		}


		bool _isExpanded;
		public bool IsExpanded
		{
			get { return _isExpanded; }
			set
			{
				_isExpanded = value;
				RaisePropertyChanged("IsExpanded");
			}
		}

        public double ZeitTotal
        {
            get
            {
                var zeit = (from dz in this where dz.ZeitEinheitTyp == enums.enZeiteinheit.Arbeit select dz.Zeit);
                double total = 0.0;
                foreach (var z in zeit)
                    total += z;

                return Math.Round(total, 2);
            }
        }
	}
}
